package define

import "github.com/gin-gonic/gin"

//主要用来封装返回结果

// type R struct {
// 	Code   int    `json:"code"`
// 	Msg    string `json:"msg"`
// 	Result any    `json:"result"`
// }

func ErrorResult(msg string) gin.H {
	code := -1
	return gin.H{
		"code": code,
		"msg":  msg,
	}
}

func SuccessResult(msg string) gin.H {
	code := 200
	return gin.H{
		"code": code,
		"msg":  msg,
	}
}

func SuccessResultWithData(msg string, result any) gin.H {
	code := 200
	return gin.H{
		"code":   code,
		"msg":    msg,
		"result": result,
	}
}
